home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / f_cvf.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  70 lines

  1. ;$Id: f_cvf.pro,v 1.3 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1994-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5. ;+
  6. ; NAME:
  7. ;       F_CVF
  8. ;
  9. ; PURPOSE:
  10. ;       This function computes the cutoff value (v) such that:
  11. ;                   Probability(X > v) = p
  12. ;       where X is a random variable from the F distribution with
  13. ;       (dfn) and (dfd) degrees of freedom.
  14. ;
  15. ; CALLING SEQUENCE:
  16. ;     Result = f_cvf(P, DFN, DFD)
  17. ;
  18. ; INPUTS:
  19. ;       P:    A non-negative scalar, in the interval [0.0, 1.0], of 
  20. ;             type float or double that specifies the probability of 
  21. ;             occurance or success. 
  22. ;
  23. ;     DFN:    A positive scalar of type integer, float or double that
  24. ;             specifies the degrees of freedom of the F distribution
  25. ;             numerator.
  26. ;
  27. ;     DFD:    A positive scalar of type integer, float or double that
  28. ;             specifies the degrees of freedom of the F distribution
  29. ;             denominator.
  30. ;
  31. ; EXAMPLE:
  32. ;       Compute the cutoff value (v) such that Probability(X > v) = 0.100
  33. ;       from the F distribution with (dfn = 10) and (dfd = 6) degrees of 
  34. ;       freedom. The result should be 7.87413
  35. ;         result = f_cvf(0.01, 10, 6)        
  36. ;
  37. ; REFERENCE:
  38. ;       APPLIED STATISTICS (third edition)
  39. ;       J. Neter, W. Wasserman, G.A. Whitmore
  40. ;       ISBN 0-205-10328-6
  41. ;
  42. ; MODIFICATION HISTORY:
  43. ;       Modified by:  GGS, RSI, July 1994
  44. ;                     Minor changes to code. New documentation header.
  45. ;-
  46.  
  47. function f_cvf, p, dfn, dfd
  48.  
  49.   on_error, 2  ;Return to caller if error occurs.
  50.  
  51.   if p lt 0. or p gt 1. then message, $
  52.     'p must be in the interval [0.0, 1.0]'
  53.  
  54.   case 1 of
  55.     dfd eq 1: up = 300.0 
  56.     dfd eq 2: up = 100.0 
  57.     dfd gt 2 and dfd le 5: up = 30.0
  58.     dfd gt 5 and dfd le 14: up = 20.0
  59.     else: up = 12.0
  60.   endcase
  61.   below = 0
  62.   while f_pdf(up, dfn, dfd) lt (1 - p) do begin
  63.     below = up
  64.     up = 2 * up
  65.   endwhile
  66.  
  67.   return, bisect_pdf([1-p, dfn, dfd], 'f_pdf', up, below)
  68. end
  69.  
  70.